home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / AIAT / Headers / Corpus / HFSCorpus.h next >
Encoding:
Text File  |  1998-04-16  |  4.7 KB  |  169 lines  |  [TEXT/CWIE]

  1. // HFSCorpus.h
  2. //    Copyright:    © 1994 - 1998 by Apple Computer, Inc., all rights reserved.
  3.  
  4. // a corpus implementation for Macintosh HFS files
  5.  
  6. #pragma once
  7. #ifndef HFSCorpus_h
  8. #define HFSCorpus_h
  9.  
  10. #pragma import on
  11.  
  12. #if PRAGMA_STRUCT_ALIGN
  13.     #pragma options align=power
  14. #endif
  15.  
  16. #include "IACorpus.h"
  17.  
  18. #include <Types.h>
  19.  
  20. #pragma IA_BEGIN_EXPORTS
  21.  
  22. const uint32    HFSCorpusType = 'HFS0';
  23.  
  24. /// HFSVolumeInfo
  25.  
  26. class HFSVolumeInfo : public IAStorable {
  27. public:
  28.                 HFSVolumeInfo() : name(NULL) {}
  29.                 HFSVolumeInfo(short vRefNum);
  30.                 ~HFSVolumeInfo();
  31.  
  32.     
  33.     // methods to store a HFSVolumeInfo
  34.     IABlockSize    StoreSize() const;
  35.     void        Store(IAOutputBlock* output) const;
  36.     IAStorable*    Restore(IAInputBlock* input) const;
  37.     IAStorable*    DeepCopy() const;
  38.     
  39.     short GetVolumeRefNum() const {return vRefNum;}
  40.     StringPtr GetVolumeName() const {return name;}
  41.     long GetCreationDate() const {return creationDate;}
  42.  
  43.     void SetVolumeRefNum(short refNum) {vRefNum = refNum;}
  44.     void SetVolumeName(StringPtr vname) {name = vname;}
  45.     void SetCreationDate(long cDate) {creationDate = cDate;}
  46.  
  47. private:
  48.                 HFSVolumeInfo(short v, StringPtr n, long c) : vRefNum(v), name(n), creationDate(c) {}
  49.     short        FindVRefNum(const StringPtr name, long creationDate) const;
  50.  
  51.                 HFSVolumeInfo(HFSVolumeInfo&);    // don't define a copy constructor
  52.                 
  53.     short        vRefNum;                    // volume reference number (ephemeral)
  54.     StringPtr    name;                        // volume name (persistent)
  55.     long        creationDate;                // volume creation date (persistent)
  56.  
  57. };
  58.  
  59. IAExceptionCode        HFSVolumeNotFound = 'VCHV';
  60. IAExceptionCode        HFSError =             'VCHE';
  61.  
  62. class HFSCorpus : public IACorpus {
  63. public:    
  64.                 HFSCorpus(uint32 type = HFSCorpusType)
  65.                     : volumeInfos(NULL), volumeCount(0), IACorpus(type) {}
  66.         virtual        ~HFSCorpus();
  67.  
  68.     // IACorpus methods
  69.     IADoc*        GetProtoDoc();
  70.     IADocText*    GetDocText(const IADoc* doc);
  71.     
  72.     // HFSCorpus-specific methods
  73.     unsigned short    GetVRefID(short vRefNum);
  74.     short            GetVRefNum(unsigned short vRefID);
  75.     
  76. protected:
  77.     IABlockSize    InitialSize();
  78.     void        Initializing(IAOutputBlock* output);
  79.     void        Opening(IAInputBlock* input);
  80.     IABlockSize    UpdateSize();
  81.     void        Updating(IAOutputBlock* output);
  82.  
  83.     void            DeleteVolumeInfos();
  84.  
  85.     void SetVolumeInfos (HFSVolumeInfo** vinfos) {volumeInfos = vinfos;}
  86.     void SetVolumeCount(short vCount) {volumeCount = vCount;}
  87.     
  88.     HFSVolumeInfo** GetVolumeInfos () const {return volumeInfos;}
  89.     short GetVolumeCount() const {return volumeCount;}
  90.  
  91. private:
  92.                 HFSCorpus(HFSCorpus&);        // don't define a copy constructor
  93.     HFSVolumeInfo** volumeInfos;            // array mapping from vRefID to HFSVolumeInfo
  94.     short            volumeCount;            // length of the array
  95.                 
  96.                 
  97. };
  98.  
  99. class HFSDoc : public IADoc {
  100. public:
  101.                 HFSDoc(HFSCorpus* corpus, short vRefNum, long dirID, const StringPtr name);
  102.                 HFSDoc() : fileName(NULL) {}
  103.     virtual        ~HFSDoc();
  104.  
  105.     IAStorable*    DeepCopy() const;
  106.     IABlockSize    StoreSize() const;
  107.     void        Store(IAOutputBlock* output) const;
  108.     IAStorable*    Restore(IAInputBlock* input) const;
  109.  
  110.     bool        LessThan(const IAOrderedStorable* neighbor) const;
  111.     bool        Equal(const IAOrderedStorable* neighbor) const;
  112.     
  113.     byte*        GetName(uint32 *length) const;
  114.     
  115.     void             SetVolumeRefID(unsigned short vrid) {vRefID = vrid;}
  116.     void             SetDirID(long dID) {dirID = dID;}
  117.     void             SetFileName(StringPtr name) {fileName = name;}
  118.     unsigned short     GetVolumeRefID() const {return vRefID;}
  119.     long             GetDirID() const {return dirID;}
  120.     StringPtr         GetFileName() const {return fileName;}
  121.     
  122.     
  123. protected:
  124.     void        DeepCopying(const IAStorable* source);
  125.     void        Restoring(IAInputBlock* input, const IAStorable* proto);
  126. private:
  127.                 HFSDoc(HFSDoc& fd);            // don't define a copy constructor
  128.     unsigned short    vRefID;                    // not a vRefNum! use as arg to GetVRefNum().
  129.     long            dirID;
  130.     StringPtr        fileName;                // alloated with IAMallocArraySized
  131.  
  132. };
  133.  
  134. class HFSDocText : public IADocText {
  135. public:
  136.                             HFSDocText() : refNum(0) {}
  137.                             HFSDocText(short vRefNum, long dirID, const StringPtr name);
  138.                             ~HFSDocText();
  139.     
  140.     uint32                    GetNextBuffer(byte* buffer, uint32 bufferLength);
  141.     IADocText*                DeepCopy() const;    
  142. protected:
  143.         void SetRefNum (short rNum) {refNum = rNum;}
  144.         void SetTheVolumeRefNum(short vrnum) {theVRefNum = vrnum;}
  145.         void SetTheDirID(long did) {theDirID = did;}
  146.         void SetTheFileName(StringPtr name) {theFileName = name;}
  147.         
  148.         short         GetRefNum () const {return refNum;}
  149.         short         GetTheVolumeRefNum() const {return theVRefNum;}
  150.         long         GetTheDirID() const {return theDirID;}
  151.         StringPtr     GetTheFileName() const {return theFileName;}
  152.         
  153. private:
  154.                             HFSDocText(HFSDocText&);    // don't define a copy constructor
  155.  
  156.     short                    refNum;
  157.     short                    theVRefNum;            
  158.     long                    theDirID;            
  159.     StringPtr                theFileName;        
  160. };
  161.  
  162. #pragma IA_END_EXPORTS
  163.  
  164. #if PRAGMA_STRUCT_ALIGN
  165.     #pragma options align=reset
  166. #endif
  167.  
  168. #pragma import reset
  169. #endif